package com.bjsxt.controller;

import com.bjsxt.pojo.PageA;
import com.bjsxt.pojo.Role;
import com.bjsxt.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    //修改角色实现
   @RequestMapping("/changeRole")
    public Integer changeRole(Role role,Integer[] mids){
        return roleService.change(role, mids);
    }
//查询角色实现
    @RequestMapping("/findAllRole")
    public PageA<Role> findAllRole(Integer page,Integer rows){
        return roleService.findAll(page,rows);
    }
    //查询指定角色下菜单实现
    @RequestMapping("/findMoreRM")
    public List<Integer>  findMoreRM(Integer rid){

        return  roleService.findMoreRM(rid);
    }
    //添加角色
    @RequestMapping("/saveRole")
    public  Integer saveRole(Role role,Integer[] mids){
        return roleService.save(role, mids);
    }
    //删除角色实现
    @RequestMapping("/removeRole")
    public  Integer removeRole(Integer rid){
       return  roleService.remove(rid);
    }
//查询所有角色下拉框的实现
    @RequestMapping("/findAll2")
    public List<Role> findAll2(){
       return  roleService.findAll2();
    }
}
